![]() |
Java Database Programming with JDBC
by Pratik Patel Coriolis, The Coriolis Group ISBN: 1576100561 Pub Date: 10/01/96 |
Previous | Table of Contents | Next |
This chapter ends our journey through the JDBC. Ive provided a summary of the class interfaces and exceptions that are available in the JDBC API version 1.01, which was the most current version at the time of this writing. Although this chapters primary purpose is to serve as a reference, you should still read through the sections completely so that you are aware of all the constructors, variables, and methods available.
Well begin with the class listings. Each class listing includes a description and the class constructors, methods, and variables.
This class extends the java.util.Date object. But unlike the java util.Date, which stores time, this class stores the day, year, and month. This is for strict matching with the SQL date type.
Constructors
Constructor | Additional Description |
---|---|
Date(int Year, int Month, int day) | Construct a java.sql.Date object with the appropriate parameters |
Methods
Method Name | Additional Description |
---|---|
public String toString() | Formats a Date object as YYYY-MM-DD |
public static Date valueOf (String str) | Converts a String str to an sql.Date object |
This class is used to load a JDBC driver and establish it as an available driver. It is usually not instantiated, but is called by the JDBC driver.
Constructors
DriverManager()
Methods
Method Name | Additional Description |
---|---|
public static void deregisterDriver(Driver-JDBCdriver) throws SQLException | Drops a driver from the available drivers list |
public static synchronized Connection getConnection(String URL) throws SQLException | |
public static synchronized Connection getConnection(String URL, String LoginName, String LoginPassword) throws SQLException | |
public static synchronized Connection getConnection(String URL, Properties LoginInfo) throws SQLException | Establishes a connection to the given database URL, with the given parameters |
public static Driver getDriver(String URL) throws SQLException | Finds a driver that understands the JDBC URL from the registered driver list |
public static Enumeration getDrivers() | Gets an Enumeration of the available JDBC drivers |
public static int getLoginTimeout() | Indicates the maximum time (seconds) that a driver will wait when logging into a database |
public static PrintStream getLogStream() | Gets the logging PrintStream used by the DriverManager and JDBC drivers |
public static void println(String msg) | Sends msg to the current JDBC logging stream (fetched from above method) |
public static synchronized void register Driver(Driver JDBCdriver) throws SQLException | Specifies that a new driver class should call registerDriver when loading to register with the DriverManager |
public static void setLoginTimeout(int sec) | Indicates the time (in seconds) that all drivers will wait when logging into a database |
public static void setLogStream (PrintStream log) | Define the PrintStream that logging messages are sent to via the println method above |
This class is for developers who want to obtain and set properties for a loaded JDBC driver. Its not necessary to use this class, but it is useful for debugging JDBC drivers and advanced development.
Constructors
Constructor | Additional Description |
---|---|
public DriverPropertyInfo (String propName, String propValue) | The propName is the name of the property, and propValue is the current value; if its not been set, it may be null |
Variables
Variable Name | Additional Description |
---|---|
choices | If the property value is part of a set of values, then choices is an array of the possible values |
description | The propertys description |
name | The propertys name |
required | This is true if this property is required to be set during Driver.connect |
value | The current value of the property |
This special fixed-point, high precision number class is used to store the SQL data types NUMERIC and DECIMAL.
Constructors
Constructor | Additional Description |
---|---|
public Numeric(String strNum) | Produces a Numeric object from a string; strNum can be in one of two formats: 1234.32 or 3.1E8 |
public Numeric(String strNum, int scale) | Produces a Numeric, and scale is the number of digits right of the decimal |
public Numeric(int intNum) | Produces a Numeric object from an int Java type parameter |
public Numeric(int intNum, int scale) | Produces a Numeric object from an int, and scale gives the desired number of places right of the decimal |
public Numeric(long x) | Produces a Numeric object from a long Java type parameter |
public Numeric(long x, int scale) | Produces a Numeric object from a long parameter, and scale gives the desired number of places right of the decimal |
public Numeric(double x, int scale) | Produces a Numeric object from a double Java type parameter, and scale gives the desired number of places right of the decimal |
public Numeric(Numeric num) | Produces a Numeric object from a Numeric |
public Numeric(Numeric num, int scale) | Produces a Numeric object from a Numeric, and scale gives the desired number of places right of the decimal |
Previous | Table of Contents | Next |